<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRechargeMobileOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('recharge_mobile_order', function (Blueprint $table) {
            $table->increments('id');
            $table->string("order_sn",30)->default('')->comment("订单号");
            $table->integer("uid")->default(0)->comment("用户ID");
            $table->integer("recharge_package_id")->default(0)->comment("充值套餐ID");
            $table->integer("coupon_id")->default(0)->comment("优惠券ID");
            $table->integer("coupon_type")->default(0)->comment("优惠券类型 参照优惠券表字段");
            $table->integer("coupon_amount")->default(0)->comment("优惠券金额");
            $table->integer("recharge_amount")->default(0)->comment("充值金额（分）");
            $table->integer("pay_amount")->default(0)->comment("实际付款金额（分）");
            $table->string("mobile",15)->default('')->comment("充值手机号");
            $table->integer("discount")->default(0)->comment("折扣");
            $table->tinyInteger("months",2)->default(0)->comment("充值月份");
            $table->string("pay_type",20)->default('')->comment("支付方式");
            $table->dateTime("pay_time")->default('0000-00-00 00:00:00')->comment("支付时间");
            $table->string("pay_sn",80)->default('')->comment("支付平台单号");
            $table->tinyInteger("order_status",1)->default(0)->comment("订单状态 1未支付 2已支付 3部分已充值 4充值完成 5已取消 6已退款 ");
            $table->tinyInteger("is_first",1)->default(0)->comment("是否是用户首单  0否 1是");
            $table->string("note",255)->default('')->comment("备注");
            $table->string("app_platform",10)->default('')->comment('应用平台ios or android or wechat');
            $table->string("app_channel",30)->default('')->comment("应用市场");
            $table->string("app_version",10)->default('')->comment("APP版本");
            $table->string("app_name",20)->default('')->comment("app_name");
            $table->tinyInteger("is_deleted",1)->default(0)->comment("是否删除");
            $table->dateTime("deleted_at")->default('')->comment("删除时间");
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('recharge_mobile_order');
    }
}
